/**
 * 
 */
package com.ms.game.itembox.message;

import java.util.ArrayList;

import com.ms.game.itembox.Item;
import com.ms.game.itembox.container.ItemBoxBin;

/**
 * 給 client 的道具資料格式
 * <p>
 * 簡化的 {@link Item}
 * 
 * @author TW15010
 */
public class SSimpleItem {

	/**
	 * 唯一序號
	 */
	private String sn;

	/**
	 * 數據表 {@link ItemBoxBin} 中對應的 key
	 */
	private String itemId;

	/**
	 * 堆疊數量
	 */
	private Integer count;

	/**
	 * 精煉期結束時間
	 */
	private Long refineEndTime;

	/**
	 * 精煉階數
	 */
	private Integer refineLevel;
	
	/**
	 * 過期時間
	 */
	private Long expireTime;
	
	/**
	 * 動態數值
	 * 例如
	 * C幣卡 要給的C幣金額
	 * 升級卡 要升的等級
	 */
	private ArrayList<Object> dynamicValues;

	/**
	 * 給clinet的格式轉成json
	 */
	public SSimpleItem toClientJsonFormat(){		
		if(count == 0){
			count = null;
		}
		
		if(refineEndTime == 0){
			refineEndTime = null;
		}
		
		if(refineLevel == 0){
			refineLevel = null;
		}
		
		if(expireTime == 0){
			expireTime =null;
		}
		
		if (dynamicValues == null || dynamicValues.size() <= 0) {
			dynamicValues = null;
		} else {
			for (Object object : dynamicValues) {
				if (object instanceof SSimpleItem) {
					SSimpleItem simpleItem = (SSimpleItem) object;
					simpleItem.toClientJsonFormat();
				}
			}
		}
		return this;
	}
	
	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append(sn + "|" + itemId + "|" + count);
		return sb.toString();
	}

	public String getSn() {
		return sn;
	}

	public void setSn(String sn) {
		this.sn = sn;
	}

	public String getItemId() {
		return itemId;
	}

	public void setItemId(String itemId) {
		this.itemId = itemId;
	}

	public Integer getCount() {
		return count;
	}

	public void setCount(Integer count) {
		this.count = count;
	}

	public Long getRefineEndTime() {
		return refineEndTime;
	}

	public void setRefineEndTime(Long refineEndTime) {
		this.refineEndTime = refineEndTime;
	}

	public Integer getRefineLevel() {
		return refineLevel;
	}

	public void setRefineLevel(Integer refineLevel) {
		this.refineLevel = refineLevel;
	}

	public Long getExpireTime() {
		return expireTime;
	}

	public void setExpireTime(Long expireTime) {
		this.expireTime = expireTime;
	}

	public ArrayList<Object> getDynamicValues() {
		return dynamicValues;
	}

	public void setDynamicValues(ArrayList<Object> dynamicValues) {
		this.dynamicValues = dynamicValues;
	}

}
